<template>
	<view>
		<span>{{count}}</span>
	</view>
</template>

<script>
	export default{
		props:{
			num:{
				type:Number,
				default:0
			},
			durtion:{
				type:Number,
				default:3000
			}
		},
		data(){
			return{
				count:0
			}
		},
		methods:{
			startUp(){
				if(this.num==0){return}
				let numLength = this.num.toString().length
				let res = this.num * 10 / this.durtion 
				let ppi = res>1 ? res :1
				this.timer = setInterval(()=>{
					if(this.count >= this.num){
						clearInterval(this.timer)
						this.count = this.num
						return
					}
					this.count+=Math.floor(ppi)
				},1)
			}
		},
		mounted() {
			this.startUp()
		}
	}
</script>

<style>
</style>